package permutationAndCombination;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class Combination {

    @Test
    public void testCombination() {
        bt(5, 0, 3, new ArrayList<>());
    }

    private void bt(int total, int begin, int count, List<Integer> idxList) {
        if (begin == total && count > 0) {
            return;
        } else if (count == 0) {
            System.out.println(idxList);
        } else {
            for (int i = begin; i < total; i++) {
                //选
                idxList.add(i);
                bt(total, i + 1, count - 1, idxList);
                idxList.remove(idxList.size() - 1);
            }
        }
    }
}
